package com.crm.controller;


import com.crm.constant.dto.BaseFxResponse;
import com.crm.entity.CrmArticle;
import com.crm.entity.CrmSite;
import com.crm.model.bo.ArticlePageBo;
import com.crm.model.bo.EmployeeBo;
import com.crm.model.bo.ProjectBo;
import com.crm.model.bo.ProjectPageBo;
import com.crm.model.dto.BasePageResult;
import com.crm.model.vo.ProjectVo;
import com.crm.service.ICrmProjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CRM_SYSTEM
 * @since 2022-03-30
 */
@RestController
@RequestMapping("/crm-project")
public class CrmProjectController {

    @Autowired
    private ICrmProjectService projectService;

    @ApiOperation("新增项目")
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public BaseFxResponse<Long> saveProject(@RequestBody @Validated ProjectBo projectBo){
        return projectService.saveProject(projectBo);
    }
    @ApiOperation("根据Id查询项目")
    @RequestMapping(value = "/queryById", method = RequestMethod.GET)
    public BaseFxResponse<ProjectVo> queryPorById(@RequestParam("id") Long id) {
        return projectService.queryPorById(id);
    }
    @ApiOperation("分页查询项目")
    @RequestMapping(value = "/query/page",method = RequestMethod.POST)
    public BaseFxResponse<BasePageResult<ProjectVo>> queryPage(@RequestBody @Validated ProjectPageBo pageBo){
        return projectService.queryPage(pageBo);
    }
    @ApiOperation("根据Id更新项目")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public BaseFxResponse<Long> updateProject(@RequestBody @Validated ProjectBo projectBo){
        return projectService.updateProject(projectBo);
    }
    @ApiOperation("变更项目状态")
    @RequestMapping(value = "/update/status",method = RequestMethod.GET)
    public BaseFxResponse<Long> updateProjectStatus(@RequestParam("projectId")Long projectId,@RequestParam("status")Integer status){
        return projectService.updateProjectStatus(projectId,status);
    }

}

